<template>
<el-card style="width:80%;margin:10px">
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="密码">
      <el-input v-model="form.pass" type="password" autocomplete="off"/>
    </el-form-item>
        <el-form-item label="重复密码">
      <el-input v-model="form.comfirm" type="password" autocomplete="off"/>
    </el-form-item>

        <el-form-item label="新密码">
      <el-input v-model="form.newpwd" type="password" autocomplete="off"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="PasswordChange">保存</el-button>
    </el-form-item>
  </el-form>

</el-card>

</template>

<script>
import request from "@/utils/request";

export default {
  name: "PasswordChange",
  data(){
    let u=sessionStorage.getItem('user');
    let form={
      'id':u.id,
      'pass':null,
      'confirm':null,
    }
    return{
      form
    }
  },
  methods:{
    PasswordChange(){
      // if(!this.form.confirm===this.form.pass){
      //   this.$message({type:"error",message:"两次密码输入不一致"})
      //   return
      // }
    let a=sessionStorage.getItem('user');
    let u=JSON.parse(a)
    console.log(u)
        let user={
        "address":u.address,
        "gender":u.gender,
        "id":u.id,
        "status":u.status,
        "userName":u.userName,
        "email":u.email,
        "userPwd":this.form.newpwd,
        'bankName':u.bankName,
        "createTime":u.createTime
        }
        console.log(user)
      request.put("/user",user).then(res=>{
        console.log(res)
        if(res.code==='0'){
          this.$message({
            type:"success",
            message:"密码修改成功"
          })

        }else {
          this.$message({
            type:"error",
            message:"修改失败"
          })
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
